home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------*/
- /* */
- /* */
- /* ------------ Bit-Bucket Software <no-Inc> */
- /* \ 10001101 / Writers and Distributors of */
- /* \ 011110 / No-Cost<no-tm> Software. */
- /* \ 1011 / */
- /* ------ KopyRong (K) 1987. ALL RIGHTS REVERSED. */
- /* */
- /* */
- /* This module was written by Vince Perriello */
- /* */
- /* */
- /* BinkleyTerm OMMM Control File Generator */
- /* */
- /* */
- /* This software package is being distributed WITH FULL SOURCE CODE */
- /* with the following conditions: 1) If anything awful happens */
- /* because you use it (or don't use it), you accept full */
- /* responsibility; 2) you don't start making tons of voice calls to */
- /* the authors to complain or make suggestions about enhancements, */
- /* useful or otherwise; 3) you do not reuse this code in commercial */
- /* products without specific permission to do so from the authors; */
- /* 4) If you find any problems you send fixes to the authors for */
- /* inclusion in updates; 5) You find some way to express your */
- /* appreciation for this method of distribution, either by writing */
- /* code or application notes, or just sending along a "Thank You" */
- /* message. */
- /* */
- /* There is copyrighted code in this product. We either wrote it */
- /* ourselves or got permission to use it. Please don't force us to */
- /* pay a lawyer -- have some respect for our motives and don't abuse */
- /* this "license". */
- /* */
- /* */
- /*--------------------------------------------------------------------------*/
-
- #include <stdio.h>
- #include <signal.h>
- #include <ctype.h>
- #include <conio.h>
- #include "com.h"
- #include "xfer.h"
-
- /*--------------------------------------------------------------------------*/
- /* BTCTL */
- /* Parse the BINKLEY.CFG file and write out a BINKLEY.PRM file (for use by */
- /* OMMM) and a MAIL.SYS file (for use by FASTTOSS, SCANMAIL, SIRIUS, etc). */
- /* If the environment variable BINKLEY exists use the path specified for */
- /* ALL input and output files. */
- /*--------------------------------------------------------------------------*/
-
-
-
- /*--------------------------------------------------------------------------*/
- /* MAIL.SYS file structure */
- /*--------------------------------------------------------------------------*/
- struct _mail
- begin
- int pri_node; /* Our node number */
- float fudge; /* Unknown/unused */
- int rate; /* Maximum baud rate */
- char mailpath[80]; /* Path for incomming messages */
- char filepath[80]; /* Path for incomming files */
- int pri_net; /* Our network number */
- int alt_node; /* Alternate node number (mainly for HOSTS) */
- int alt_net; /* Alternate net number (mainly for HOSTS) */
- end;
- struct _mail mailsys; /* MAIL.SYS used by SIRIUS */
- struct pointers ctl; /* where the .CTL stuff is */
-
- char *temp_sysop = NULL;
- char *temp_system_name = NULL;
- char *temp_hold_area = NULL;
- char *ctl_string();
-
- int num_addrs = 1;
-
- main()
- {
- char *envptr,*envget();
- char *malloc();
- FILE *stream;
- char temp[80],temp2[80];
- char *c;
- char *skip_blanks();
- int i;
-
- /*
- * Initialize the fields that we care about
- */
- ctl.our_zone = 1; /* Default to Zone 1 */
- ctl.version = THIS_CTL_VERSION; /* Have to set a version */
- temp[0] = '\0'; /* "null-terminated string" */
- for (i = 0; i < ALIAS_CNT; i++) /* Zero out all aliases */
- ctl.alias[i].net = ctl.alias[i].node = 0;
- mailsys.pri_node = mailsys.pri_net = mailsys.alt_node = mailsys.alt_net = 0;
- for (i = 0; i < 80; i++) /* Clean out the strings */
- mailsys.mailpath[i] = mailsys.filepath[i] = '\0';
- strcpy (temp, "Binkley.Cfg");
- if ((stream = fopen(temp,"r")) == NULL) /* OK, let's open the file */
- {
- envptr = envget("BINKLEY"); /* get path from environment */
- if (envptr != NULL) /* if there was one, */
- strcpy(temp,envptr); /* use it to get things going*/
- strcat(temp,"Binkley.cfg"); /* add in the file name */
- if ((stream = fopen(temp,"r")) == NULL) /* OK, let's open the file */
- errxit("Unable to open BINKLEY.CFG");
- }
-
- while((fgets(temp,79,stream)) != NULL) /* Now we parse the file ... */
- {
- c = temp; /* Check out the first char */
- if ((*c == '%') || (*c == ';')) /* See if it's a comment line*/
- continue;
-
- i = strlen(temp); /* how long this line is */
- if (i < 6) /* treat something SHORT */
- continue; /* as a comment line */
-
- c = &temp[--i]; /* point at last character */
- if (*c == '\n') /* if it's a newline, */
- *c = '\0'; /* strip it off */
-
-
- if (strnicmp(temp,"zone",4) == 0) /* Zone we are in */
- {
- c = skip_blanks(&temp[4]);
- ctl.our_zone = atoi(c);
- if (!ctl.our_zone) /* if we didn't find a zone */
- {
- sprintf(temp2,"Illegal zone: %s\n", &temp[4]);
- errxit(temp2);
- }
- continue;
- }
-
- if (strnicmp(temp,"point",5) == 0) /* if this is my point name */
- {
- c = skip_blanks(&temp[5]);
- sscanf(c,"%d/%d",&ctl.alias[0].net,&ctl.alias[0].node);
- mailsys.pri_net = ctl.alias[0].net;
- mailsys.pri_node = ctl.alias[0].node;
- continue;
- }
-
- if (strnicmp(temp,"aka",3) == 0) /* if this is an AKA name */
- {
- c = skip_blanks(&temp[3]);
- sscanf(c,"%d/%d",&ctl.alias[num_addrs].net,&ctl.alias[num_addrs].node);
- if (num_addrs == 1)
- {
- mailsys.pri_net = ctl.alias[1].net;
- mailsys.pri_node = ctl.alias[1].node;
- }
- ++num_addrs;
- continue;
- }
-
- if (strnicmp(temp,"boss",4) == 0) /* If this is my boss name */
- {
- c = skip_blanks(&temp[4]);
- continue;
- }
-
- if (strnicmp(temp,"netfile",7) == 0) /* inbound file area */
- {
- c = skip_blanks(&temp[7]);
- strcpy(mailsys.filepath,c); /* copy it */
- continue;
- }
-
- if (strnicmp(temp,"netmail",7) == 0) /* matrix message area */
- {
- c = skip_blanks(&temp[7]);
- strcpy(mailsys.mailpath,c); /* copy it */
- continue;
- }
-
- if (strnicmp(temp,"system",6) == 0) /* if this is system name */
- {
- temp_system_name = ctl_string(&temp[6]);
- continue;
- }
-
- if (strnicmp(temp,"sysop",5) == 0) /* if this is my name */
- {
- temp_sysop = ctl_string(&temp[5]);
- continue;
- }
-
- if (strnicmp(temp,"hold",4) == 0) /* matrix hold area */
- {
- temp_hold_area = ctl_string(&temp[4]);
- continue;
- }
-
- if (strnicmp(temp,"nodelist",8) == 0) /* if a nodelist spec, */
- {
- ctl.net_info = ctl_string(&temp[8]);
- continue;
- }
- }
- fclose(stream); /* close input file */
- /*
- * Okay, we have the nodelist data from the BINKLEY.CFG file.
- * Now write it into a BINKLEY.PRM file.
- */
- if (ctl.alias[0].net == 0) /* Got to have at least our */
- errxit("No Network Address was entered");/* own address!! */
- if (envptr != NULL) /* If there was a BINKLEY, */
- strcpy(temp,envptr); /* use it here too */
- else
- temp[0] = '\0';
- strcat(temp,"Binkley.Prm"); /* add in the file name */
- if ((stream = fopen(temp,"wb")) == NULL) /* OK, let's open the file */
- errxit("Unable to open BINKLEY.PRM");
- if (fwrite(&ctl,sizeof(ctl),1,stream) != 1) /* Try to write the data out */
- errxit("Could not write control file data to BINKLEY.PRM");
- fclose(stream); /* close output file */
- printf("Control file successfully written\n"); /* Notify user of success */
-
- if (envptr != NULL) /* If there was a BINKLEY, */
- strcpy(temp,envptr); /* use it here too */
- else
- temp[0] = '\0';
- strcat(temp,"Mail.Sys"); /* add in the file name */
- if ((stream = fopen(temp,"wb")) == NULL) /* OK, let's open the file */
- errxit("Could not open MAIL.SYS"); /* no file, no work to do */
- if (fwrite(&mailsys,sizeof(mailsys),1,stream) != 1)
- errxit("Unable to write data to MAIL.SYS");/* Try to write the data out */
- fclose(stream); /* close output file */
- printf("MAIL.SYS file successfully written\n"); /* Notify user of success */
- }
-
- errxit(error)
- char *error;
- {
- printf("\r\n%s\n",error);
- exit(0);
- }
-
- char *ctl_string(source) /* malloc & copy to ctl */
- char *source;
- {
- char *malloc();
- char *dest, *c;
- c = skip_blanks(source); /* get over the blanks */
- dest = malloc(strlen(c)+1); /* allocate space for string */
- strcpy(dest,c); /* copy the stuff over */
- return(dest); /* and return the address */
- }
-
- char *skip_blanks(string)
- char *string;
- {
- while (*string == ' ' || *string == '\t')
- ++string;
- return(string);
- }
-
- /*
- * envget - routine to find environment variables, copy them
- * into a local string, then pass the string back. It's the caller's
- * responsibility to handle re-entrancy problems. Usually the result
- * of this operation is transient.
- */
- static char env_value[80];
-
- char *envget(string)
- char *string;
- {
- char *dev,*getenv();
- if ((dev = getenv(string)) != NULL)
- {
- strcpy(env_value,dev);
- return(env_value);
- }
- env_value[0] = '\0'; /* put nothing there */
- return(env_value); /* if we got nothing give nothing */
- }